/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package pvt.delez.pam.virgin.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import pvt.delez.pam.virgin.BuildCommand;
import pvt.delez.pam.virgin.ProjectDescriptor;
import pvt.delez.pam.virgin.VirginPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Project Descriptor</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link pvt.delez.pam.virgin.impl.ProjectDescriptorImpl#getName <em>Name</em>}</li>
 *   <li>{@link pvt.delez.pam.virgin.impl.ProjectDescriptorImpl#getProjects <em>Projects</em>}</li>
 *   <li>{@link pvt.delez.pam.virgin.impl.ProjectDescriptorImpl#getBuildCommands <em>Build Commands</em>}</li>
 *   <li>{@link pvt.delez.pam.virgin.impl.ProjectDescriptorImpl#getNatures <em>Natures</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ProjectDescriptorImpl extends EObjectImpl implements ProjectDescriptor {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getProjects() <em>Projects</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProjects()
	 * @generated
	 * @ordered
	 */
	protected EList<ProjectDescriptor> projects;

	/**
	 * The cached value of the '{@link #getBuildCommands() <em>Build Commands</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBuildCommands()
	 * @generated
	 * @ordered
	 */
	protected EList<BuildCommand> buildCommands;

	/**
	 * The cached value of the '{@link #getNatures() <em>Natures</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNatures()
	 * @generated
	 * @ordered
	 */
	protected EList<String> natures;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProjectDescriptorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return VirginPackage.Literals.PROJECT_DESCRIPTOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, VirginPackage.PROJECT_DESCRIPTOR__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ProjectDescriptor> getProjects() {
		if (projects == null) {
			projects = new EObjectResolvingEList<ProjectDescriptor>(ProjectDescriptor.class, this, VirginPackage.PROJECT_DESCRIPTOR__PROJECTS);
		}
		return projects;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<BuildCommand> getBuildCommands() {
		if (buildCommands == null) {
			buildCommands = new EObjectResolvingEList<BuildCommand>(BuildCommand.class, this, VirginPackage.PROJECT_DESCRIPTOR__BUILD_COMMANDS);
		}
		return buildCommands;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getNatures() {
		if (natures == null) {
			natures = new EDataTypeUniqueEList<String>(String.class, this, VirginPackage.PROJECT_DESCRIPTOR__NATURES);
		}
		return natures;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case VirginPackage.PROJECT_DESCRIPTOR__NAME:
				return getName();
			case VirginPackage.PROJECT_DESCRIPTOR__PROJECTS:
				return getProjects();
			case VirginPackage.PROJECT_DESCRIPTOR__BUILD_COMMANDS:
				return getBuildCommands();
			case VirginPackage.PROJECT_DESCRIPTOR__NATURES:
				return getNatures();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case VirginPackage.PROJECT_DESCRIPTOR__NAME:
				setName((String)newValue);
				return;
			case VirginPackage.PROJECT_DESCRIPTOR__PROJECTS:
				getProjects().clear();
				getProjects().addAll((Collection<? extends ProjectDescriptor>)newValue);
				return;
			case VirginPackage.PROJECT_DESCRIPTOR__BUILD_COMMANDS:
				getBuildCommands().clear();
				getBuildCommands().addAll((Collection<? extends BuildCommand>)newValue);
				return;
			case VirginPackage.PROJECT_DESCRIPTOR__NATURES:
				getNatures().clear();
				getNatures().addAll((Collection<? extends String>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case VirginPackage.PROJECT_DESCRIPTOR__NAME:
				setName(NAME_EDEFAULT);
				return;
			case VirginPackage.PROJECT_DESCRIPTOR__PROJECTS:
				getProjects().clear();
				return;
			case VirginPackage.PROJECT_DESCRIPTOR__BUILD_COMMANDS:
				getBuildCommands().clear();
				return;
			case VirginPackage.PROJECT_DESCRIPTOR__NATURES:
				getNatures().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case VirginPackage.PROJECT_DESCRIPTOR__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case VirginPackage.PROJECT_DESCRIPTOR__PROJECTS:
				return projects != null && !projects.isEmpty();
			case VirginPackage.PROJECT_DESCRIPTOR__BUILD_COMMANDS:
				return buildCommands != null && !buildCommands.isEmpty();
			case VirginPackage.PROJECT_DESCRIPTOR__NATURES:
				return natures != null && !natures.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (Name: ");
		result.append(name);
		result.append(", Natures: ");
		result.append(natures);
		result.append(')');
		return result.toString();
	}

} //ProjectDescriptorImpl
